package org.example.novel.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.poi.hssf.extractor.ExcelExtractor;
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.xssf.usermodel.*;
import org.example.novel.domain.User;
import org.example.novel.domain.requ.LoginUser;
import org.example.novel.exception.AuthException;
import org.example.novel.service.UserService;
import org.example.novel.mapper.UserMapper;
import org.example.novel.utlis.BeanHelper;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Service;

import java.io.*;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

/**
* @author hope
* @description 针对表【n_user】的数据库操作Service实现
* @createDate 2024-05-28 21:45:29
*/
@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User>
    implements UserService, UserDetailsService {

    @Override
    public UserDetails loadUserByUsername(String username)throws UsernameNotFoundException{

        User user = baseMapper.selectOne(new LambdaQueryWrapper<User>().eq(User::getEamil, username));

        if (user==null){
            throw new UsernameNotFoundException("用户名或密码错误");
        }

        return BeanHelper.copyProperties(user, LoginUser.class);
    }


}




